package de.fhluebeck.oop.gps.cmd;

import de.fhluebeck.oop.gps.common.Constants;
import de.fhluebeck.oop.gps.common.DependencyManager;
import de.fhluebeck.oop.gps.service.IDatabaseService;
import de.fhluebeck.oop.gps.service.IWSExportService;

/**
 * 
 * Option zum exportieren des Webservices Interfaces
 *
 * @author Ogün Bilge, Leif Hitzschke
 * @version 1.00, 13.11.2009
 * 
 * Needs Derby Server version to run correctly 
 * 
 * 
 */
public class ExportWebserviceCommand extends Option {

	private final static String KEY = "-startws";
	private Option successor;
	
	public ExportWebserviceCommand(Option successor) {
		this.successor = successor;
	}
	
	@Override
	void execute(String value) {
		
		// add Database check here;
		((IDatabaseService) DependencyManager
				.locate(Constants.DATABASE_SERVICE_DEP_NAME)).initDatabase();
		
		// export WebServices
		((IWSExportService) DependencyManager
				.locate(Constants.WSEXPORT_SERVICE_DEP_NAME)).export();
	}

	@Override
	Option getSuccessor() {
		return successor;
	}

	@Override
	boolean isApplicable(String key) {
		return KEY.equals(key);
	}
}
